package placeme

class User {
	static belongsTo = [customer:Customer, company:Company]
	String login;
	String password;
	String passwordConfirmation;
	String email;
	String name;

    static constraints = {
		customer(nullable:true)
		company(nullable:true)
		login(size:5..15, blank:false, unique:true)
        password(size:6..15, blank:false)
		passwordConfirmation(validator : {
			val, user -> 
			if(!user.properties['password'].equals(val))
				return ['invalid']
		})
        email(email:true, blank:false)
    }
	
	static transients = ['passswordConfirmation']
}
